
#ifndef EMIXER_ALSA_H
#define EMIXER_ALSA_H

#include <alsa/asoundlib.h>
#include <alsa/mixer_abst.h>

/**
 * error type enum
 */
typedef enum
{
  ERR_NONE,
  ERR_OPEN,
  ERR_FCN,
  ERR_SIGNAL,
} ErrType;

/**
 * bail out on error
 * @param error error ID
 * @param err_string description
 * @param xerrno x return
 */

static void
emixer_abort ( ErrType error, const char *err_string, int xerrno );

/**
 * init the mixer internals from
 * HW info about selected card.
 * call this first befor anything else
 * @param card_id card to access
 * @return non-zero on error
 */
int
emixer_mixer_init ( const char* card_id );

/**
 * call this to clean up before
 * going down
 */
void
emixer_mixer_deinit();

/**
 * get the cards name
 * @return name
 */
const char*
emixer_card_name_get();

/**
 * get the device name
 * @return name
 */
const char*
emixer_device_name_get();

/**
 * return the number of mixer elems
 * @return num elems or -1 on error
 */
const int
emixer_elem_num_get();

/**
 * return the mixer elements name string
 * @param idx element index
 * @return name
 */
const char*
emixer_elem_name_get ( const int idx );

/**
 * get the volume range
 * @param idx element index
 * @param min out min volume
 * @param max out max volume
 * @return none-zero on error
 */
int
emixer_elem_vol_range_get ( const int idx, long* min, long* max );

/**
 * get the current volume
 * @param idx element index
 * @param chanel the channel (left, right,ect)
 * @param vol out volume
 * @return none-zero on error
 */
int
emixer_elem_vol_now_get ( const int idx, const int chanel, long* vol );


/**
 * test if a mixer element is active
 * @param idx element index
 * @return 0 if no, none-zero if yes
 */
int
emixer_elem_is_active ( const int idx );



/**
 * set the playback volume of a given chnanel for
 * a specific mixer element
 * @param idx mixer element
 * @param chanel element channel
 * @param vol volume level
 * @return none-zero on error
 */
int
emixer_elem_vol_now_set(const int idx, const int chanel, const long vol);

/**
 * get the muted status of a given chnanel for a
 * specific mixer elment
 * @param idx mixer element
 * @param chanel element chanel
 * @return -1 on error, 0 on no, 1 on yes
 */
int
emixer_elem_mute_get(const int idx, const int chanel);

/**
 * set the muted status of a given chnanel for a
 * specific mixer elment
 * @param idx mixer element
 * @param chanel element channel
 * @param set 1 for mute 0 for unmute
 * @return -1 on error, 0 on no, 1 on yes
 */
int
emixer_elem_mute_set(const int idx, const int chanel, int set);

#endif

